<?php
try
{
    //open the database
    $db = new PDO('sqlite:Counter.db');

    //create the database
    $db->exec("CREATE TABLE Counters (Id INTEGER PRIMARY KEY, Counter INTEGER)");

    $db->exec("CREATE TABLE Hits (Id INTEGER PRIMARY KEY, 
        Counter INTEGER,
        Timestamp INTEGER,
        RemoteAddr TEXT, 
        Referer TEXT,
        SearchKeywords TEXT,
        UserAgent TEXT,
        RequestUri TEXT)");

    $db->exec("INSERT INTO Counters (Id, Counter) VALUES (1, 0)");
	
    echo "Database and Table created sucessfully.";
	
    // close the database connection
    $db = NULL;
  }
  catch(PDOException $e)
  {
    print 'Exception : '.$e->getMessage();
}
